unit Class_MOBL_GZJL;

interface
uses
  Classes,SysUtils,Uni,UniEngine;

type
  TMOBLGZJL=class(TUniEngine)
  public
    FDATATYPE: string;
  private
    FUNITLINK: string;
    FSTAFIDEX: Integer;
    FGZJGIDEX: Integer;
    FWAGEKJND: Integer;
    FWAGEKJQJ: Integer;
    FWAGEIDEX: Integer;
    FHOLDTYPE: Integer;
    FGZJGFLID: Integer;
    FGZJGFLBH: Integer;
    FFORQUERY: Integer;
    FGZJGFLMC: string;
    FGZJLTEXT: string;
    FGZJLDATA: Extended;
  protected
    procedure SetParameters;override;
    function  GetStrInsert:string;override;
    function  GetStrUpdate:string;override;
    function  GetStrDelete:string;override;
  public
    function  GetStrsIndex:string;override;
  public
    function  GetNextIdex:Integer;overload;
    function  GetNextIdex(AUniConnection:TUniConnection):Integer;overload;
  public
    function  CheckExist(AUniConnection:TUniConnection):Boolean;override;
  public
    destructor  Destroy; override;
    constructor Create;  
  published
    property DATATYPE: string read FDATATYPE write FDATATYPE;
    property UNITLINK: string read FUNITLINK write FUNITLINK;
    property STAFIDEX: Integer read FSTAFIDEX write FSTAFIDEX;
    property GZJGIDEX: Integer read FGZJGIDEX write FGZJGIDEX;
    property WAGEKJND: Integer read FWAGEKJND write FWAGEKJND;
    property WAGEKJQJ: Integer read FWAGEKJQJ write FWAGEKJQJ;
    property WAGEIDEX: Integer read FWAGEIDEX write FWAGEIDEX;
    property HOLDTYPE: Integer read FHOLDTYPE write FHOLDTYPE;
    property GZJGFLID: Integer read FGZJGFLID write FGZJGFLID;
    property GZGJFLBH: Integer read FGZJGFLBH write FGZJGFLBH;
    property FORQUERY: Integer read FFORQUERY write FFORQUERY;
    property GZJGFLMC: string read FGZJGFLMC write FGZJGFLMC;
    property GZJLTEXT: string read FGZJLTEXT write FGZJLTEXT;
    property GZJLDATA: Extended read FGZJLDATA write FGZJLDATA;
  public
    class function  ReadDS(AUniQuery:TUniQuery):TUniEngine;override;
    class procedure ReadDS(AUniQuery:TUniQuery;var Result:TUniEngine);override;
    class function  CopyIt(AMOBLGZJL:TMOBLGZJL):TMOBLGZJL;overload;        
    class procedure CopyIt(AMOBLGZJL:TMOBLGZJL;var Result:TMOBLGZJL);overload;

    class function  ExpSQL(AStafIdex,AUnitLink,AGZJGIDEX,AWAGEKJND,AWAGEKJQJ,AWAGEIDEX,AHOLDTYPE:string):string;
  end;

implementation

{ TMOBLGZJL }
procedure TMOBLGZJL.SetParameters;
begin
  inherited;
  with FUniSQL.Params do
  begin
    case FOptTyp of
      otAddx:
      begin
        ParamByName('UNIT_LINK').Value := UNITLINK;
        ParamByName('STAF_IDEX').Value := STAFIDEX;
        ParamByName('GZJG_IDEX').Value := GZJGIDEX;
        ParamByName('WAGE_KJND').Value := WAGEKJND;
        ParamByName('WAGE_KJQJ').Value := WAGEKJQJ;
        ParamByName('WAGE_IDEX').Value := WAGEIDEX;
        ParamByName('HOLD_TYPE').Value := HOLDTYPE;
        ParamByName('GZJG_FLID').Value := GZJGFLID;
        ParamByName('FOR_QUERY').Value := FORQUERY;
        ParamByName('GZJG_FLMC').Value := GZJGFLMC;
        ParamByName('GZJL_TEXT').Value := GZJLTEXT;
        ParamByName('GZJL_DATA').Value := GZJLDATA; 
      end;
      otEdit:
      begin
        ParamByName('UNIT_LINK').Value := UNITLINK;
        ParamByName('STAF_IDEX').Value := STAFIDEX;
        ParamByName('GZJG_IDEX').Value := GZJGIDEX;
        ParamByName('WAGE_KJND').Value := WAGEKJND;
        ParamByName('WAGE_KJQJ').Value := WAGEKJQJ;
        ParamByName('WAGE_IDEX').Value := WAGEIDEX;
        ParamByName('HOLD_TYPE').Value := HOLDTYPE;
        ParamByName('GZJG_FLID').Value := GZJGFLID;
        ParamByName('FOR_QUERY').Value := FORQUERY;
        ParamByName('GZJG_FLMC').Value := GZJGFLMC;
        ParamByName('GZJL_TEXT').Value := GZJLTEXT;
        ParamByName('GZJL_DATA').Value := GZJLDATA; 
      end;  
      otDelt:
      begin
        ParamByName('UNIT_LINK').Value := UNITLINK;
        ParamByName('STAF_IDEX').Value := STAFIDEX;
        ParamByName('GZJG_IDEX').Value := GZJGIDEX;
        ParamByName('WAGE_KJND').Value := WAGEKJND;
        ParamByName('WAGE_KJQJ').Value := WAGEKJQJ;
        ParamByName('WAGE_IDEX').Value := WAGEIDEX;
        ParamByName('HOLD_TYPE').Value := HOLDTYPE;
        ParamByName('GZJG_FLID').Value := GZJGFLID;
 
      end;  
    end;
  end;
end;

function TMOBLGZJL.CheckExist(AUniConnection: TUniConnection): Boolean;
begin
  Result:=CheckExist('TBL_MOBL_GZJL',['UNIT_LINK',UNITLINK,'STAF_IDEX',STAFIDEX,'GZJG_IDEX',GZJGIDEX,'WAGE_KJND',WAGEKJND,'WAGE_KJQJ',WAGEKJQJ,'WAGE_IDEX',WAGEIDEX,'HOLD_TYPE',HOLDTYPE,'GZJG_FLID',GZJGFLID],AUniConnection);
end;

function TMOBLGZJL.GetNextIdex: Integer;
begin

end;

function TMOBLGZJL.GetNextIdex(AUniConnection: TUniConnection): Integer;
begin

end;

function TMOBLGZJL.GetStrDelete: string;
begin
  Result:='DELETE FROM TBL_MOBL_GZJL WHERE   UNIT_LINK=:UNIT_LINK AND STAF_IDEX=:STAF_IDEX AND GZJG_IDEX=:GZJG_IDEX AND WAGE_KJND=:WAGE_KJND AND WAGE_KJQJ=:WAGE_KJQJ AND WAGE_IDEX=:WAGE_IDEX AND HOLD_TYPE=:HOLD_TYPE AND GZJG_FLID=:GZJG_FLID';
end;

function TMOBLGZJL.GetStrInsert: string;
begin
  Result:='INSERT INTO TBL_MOBL_GZJL'
         +'    ( UNIT_LINK, STAF_IDEX, GZJG_IDEX, WAGE_KJND, WAGE_KJQJ'
         +'    , WAGE_IDEX, HOLD_TYPE, GZJG_FLID, FOR_QUERY, GZJG_FLMC'
         +'    , GZJL_TEXT, GZJL_DATA)'
         +'    VALUES'
         +'    (:UNIT_LINK,:STAF_IDEX,:GZJG_IDEX,:WAGE_KJND,:WAGE_KJQJ'
         +'    ,:WAGE_IDEX,:HOLD_TYPE,:GZJG_FLID,:FOR_QUERY,:GZJG_FLMC'
         +'    ,:GZJL_TEXT,:GZJL_DATA)';
end;

function TMOBLGZJL.GetStrsIndex: string;
begin
  Result:=Format('%S-%D-%D-%D-%D-%D-%D-%D',[UNITLINK,STAFIDEX,GZJGIDEX,WAGEKJND,WAGEKJQJ,WAGEIDEX,HOLDTYPE,GZJGFLID]);
end;

function TMOBLGZJL.GetStrUpdate: string;
begin
  Result:='UPDATE  TBL_MOBL_GZJL SET'
         +'    FOR_QUERY=:FOR_QUERY,'
         +'    GZJG_FLMC=:GZJG_FLMC,'
         +'    GZJL_TEXT=:GZJL_TEXT,'
         +'    GZJL_DATA=:GZJL_DATA'
         +'    WHERE UNIT_LINK=:UNIT_LINK'
         +'    AND   STAF_IDEX=:STAF_IDEX'
         +'    AND   GZJG_IDEX=:GZJG_IDEX'
         +'    AND   WAGE_KJND=:WAGE_KJND'
         +'    AND   WAGE_KJQJ=:WAGE_KJQJ'
         +'    AND   WAGE_IDEX=:WAGE_IDEX'
         +'    AND   HOLD_TYPE=:HOLD_TYPE'
         +'    AND   GZJG_FLID=:GZJG_FLID';
end;

constructor TMOBLGZJL.Create;
begin
  DATATYPE:='DATA_GZJL';
end;

destructor TMOBLGZJL.Destroy;
begin

  inherited;
end;

class function TMOBLGZJL.ReadDS(AUniQuery: TUniQuery): TUniEngine;
begin
  Result:=TMOBLGZJL.Create;
  with TMOBLGZJL(Result) do
  begin
    UNITLINK:=AUniQuery.FieldByName('UNIT_LINK').AsString;
    STAFIDEX:=AUniQuery.FieldByName('STAF_IDEX').AsInteger;
    GZJGIDEX:=AUniQuery.FieldByName('GZJG_IDEX').AsInteger;
    WAGEKJND:=AUniQuery.FieldByName('WAGE_KJND').AsInteger;
    WAGEKJQJ:=AUniQuery.FieldByName('WAGE_KJQJ').AsInteger;
    WAGEIDEX:=AUniQuery.FieldByName('WAGE_IDEX').AsInteger;
    HOLDTYPE:=AUniQuery.FieldByName('HOLD_TYPE').AsInteger;
    GZJGFLID:=AUniQuery.FieldByName('GZJG_FLID').AsInteger;
    FORQUERY:=AUniQuery.FieldByName('FOR_QUERY').AsInteger;
    GZJGFLMC:=AUniQuery.FieldByName('GZJG_FLMC').AsString;
    GZJLTEXT:=AUniQuery.FieldByName('GZJL_TEXT').AsString;
    GZJLDATA:=AUniQuery.FieldByName('GZJL_DATA').AsFloat;
  end;  
end;

class procedure TMOBLGZJL.ReadDS(AUniQuery: TUniQuery; var Result: TUniEngine);
begin
  if Result=nil then Exit;
  with TMOBLGZJL(Result) do
  begin
    UNITLINK:=AUniQuery.FieldByName('UNIT_LINK').AsString;
    STAFIDEX:=AUniQuery.FieldByName('STAF_IDEX').AsInteger;
    GZJGIDEX:=AUniQuery.FieldByName('GZJG_IDEX').AsInteger;
    WAGEKJND:=AUniQuery.FieldByName('WAGE_KJND').AsInteger;
    WAGEKJQJ:=AUniQuery.FieldByName('WAGE_KJQJ').AsInteger;
    WAGEIDEX:=AUniQuery.FieldByName('WAGE_IDEX').AsInteger;
    HOLDTYPE:=AUniQuery.FieldByName('HOLD_TYPE').AsInteger;
    GZJGFLID:=AUniQuery.FieldByName('GZJG_FLID').AsInteger;
    FORQUERY:=AUniQuery.FieldByName('FOR_QUERY').AsInteger;
    GZJGFLMC:=AUniQuery.FieldByName('GZJG_FLMC').AsString;
    GZJLTEXT:=AUniQuery.FieldByName('GZJL_TEXT').AsString;
    GZJLDATA:=AUniQuery.FieldByName('GZJL_DATA').AsFloat;
  end;  
end;

class function  TMOBLGZJL.CopyIt(AMOBLGZJL: TMOBLGZJL): TMOBLGZJL;
begin
  Result:=TMOBLGZJL.Create;
  TMOBLGZJL.CopyIt(AMOBLGZJL,Result)
end;

class procedure TMOBLGZJL.CopyIt(AMOBLGZJL:TMOBLGZJL;var Result:TMOBLGZJL);
begin
  if Result=nil then Exit;
  Result.UNITLINK:=AMOBLGZJL.UNITLINK;
  Result.STAFIDEX:=AMOBLGZJL.STAFIDEX;
  Result.GZJGIDEX:=AMOBLGZJL.GZJGIDEX;
  Result.WAGEKJND:=AMOBLGZJL.WAGEKJND;
  Result.WAGEKJQJ:=AMOBLGZJL.WAGEKJQJ;
  Result.WAGEIDEX:=AMOBLGZJL.WAGEIDEX;
  Result.HOLDTYPE:=AMOBLGZJL.HOLDTYPE;
  Result.GZJGFLID:=AMOBLGZJL.GZJGFLID;
  Result.FORQUERY:=AMOBLGZJL.FORQUERY;
  Result.GZJGFLMC:=AMOBLGZJL.GZJGFLMC;
  Result.GZJLTEXT:=AMOBLGZJL.GZJLTEXT;
  Result.GZJLDATA:=AMOBLGZJL.GZJLDATA;
end;

class function TMOBLGZJL.ExpSQL(AStafIdex, AUnitLink, AGZJGIDEX, AWAGEKJND,
  AWAGEKJQJ, AWAGEIDEX, AHOLDTYPE: string): string;
begin
  Result:='SELECT * FROM TBL_WAGE_FL WHERE STAF_IDEX=%S AND UNIT_LINK=%S AND GZJG_IDEX=%S AND HOLD_TYPE=%S AND WAGE_KJND=%S AND WAGE_KJQJ=%S AND WAGE_IDEX=%S';
  Result:=Format(Result,[AStafIdex,QuotedStr(AUnitLink),AGZJGIDEX,AHoldType,AWAGEKJND,AWAGEKJQJ,AWAGEIDEX]);
end;

end.

